package com.jm.web.data.toolbar;

import com.jm.utils.AttributeBuilder;
import com.jm.utils.StringHelper;

/**
 * @author yanjie
 * Nov 9, 2011 5:36:58 PM
 */
public class MenuOption {
	protected String confirmText = "";
	protected String value = "";
	protected String id = "";
	protected String disabled= "";
	protected String css = "";
	protected String confirm = "";
	
	public String getCss() {
		return css;
	}
	public void setCss(String css) {
		this.css = css;
	}
	public String getDisabled() {
		return disabled;
	}
	public void setDisabled(String disabled) {
		this.disabled = disabled;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	
	public boolean isEnab(){
		return !Boolean.parseBoolean(this.getDisabled());
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	public String ToOutputString(){
		AttributeBuilder attr = new AttributeBuilder();
		
		if(!StringHelper.IsNullOrEmpty(this.getId())){
			attr.Set("id",this.getId());
		}
		
		if(!StringHelper.IsNullOrEmpty(this.getValue())){
			attr.Set("value",this.getValue());
		}
		
		if(!StringHelper.IsNullOrEmpty(this.getCss())){
			attr.Set("class",this.getCss());
		}
		
		if(!this.isEnab()){
			attr.Set("enab","false");
			attr.Append("class","ax-btn-disabled");
		}
		
		if(!StringHelper.IsNullOrEmpty(this.getConfirm())){
			attr.Set("confirm",this.getConfirm());
		}
		return attr.ToOutputString();
		
	}
	public String getConfirm() {
		return confirm;
	}
	public void setConfirm(String confirm) {
		this.confirm = confirm;
	}
	
	public String getConfirmText() {
		return StringHelper.getValue(confirmText, value);
	}
	public void setConfirmText(String confirmText) {
		this.confirmText = confirmText;
	}
}
